package com.google.shop.product.socket.websocket;

import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;

@Component
/* loaded from: app.jar:BOOT-INF/classes/com/google/shop/product/socket/websocket/MessageHandshakeInterceptor.class */
public class MessageHandshakeInterceptor implements HandshakeInterceptor {
    @Override // org.springframework.web.socket.server.HandshakeInterceptor
    public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Map<String, Object> attributes) throws Exception {
        String[] ss = StringUtils.split(request.getURI().getPath(), '/');
        if (ss.length != 2) {
            return false;
        }
        attributes.put("uid", ss[1]);
        return true;
    }

    @Override // org.springframework.web.socket.server.HandshakeInterceptor
    public void afterHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, Exception exception) {
    }
}
